package com.atstudy.obj;

import java.util.Objects;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/21 9:35
 * @copyright: 博为峰
 */
public class Student extends Object{
    public String name;
    public int age;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    /*public boolean equals(Object obj) {//Object obj = stu02
        Student stu02 = (Student) obj;
        String stu01Name = this.name;
        String stu02Name = stu02.name;
        if (stu01Name.equals(stu02Name) && this.age == stu02.age) {
            return true;
        }
        return false;
    }

    public int hashCode(){
        return this.name.hashCode() + age;
    }*/

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';

    }
}
